import http from '../http/request'


interface IArticlesProps {
    current?: number,
    pageSize?: number
}

interface IArticlesDelProps {
    id: string
}

// 文章列表数据
function getArticles({ current, pageSize }: IArticlesProps) {
    return http.get('/api/rest/articles', {
        params: {
            pagenum: current,
            pagesize: pageSize
        }
    })
}

// 删除文章列表数据
function delArticlesItem( { id }: IArticlesDelProps ) {
    return http.delete('/api/rest/articles/' + id)
}

// 获取文章所属分类
function getCategories() {
    return http.get('/api/rest/categories')
}

// 新增文章
function addCategories(params: any) {
    return http.post('/api/rest/articles', {
        ...params
    })
}

// 获取文章详情
function getArticlesDetail({ id }: any) {
    return http.get('/api/rest/articles/' + id)
}

// 更新文章详情
function putArticlesDetail(params: any) {
    return http.put('/api/rest/articles/' + params.id, {
        ...params
    })
}



export {
    getArticles,
    delArticlesItem,
    getCategories,
    addCategories,
    getArticlesDetail,
    putArticlesDetail
}